//
//  ProfileDetailViewController.m
//  Gradekeeper0.2
//
//  Created by Lily Wang on 11/2/09.
//  Copyright 2009 i5. All rights reserved.
//

#import "ProfileDetailViewController.h"
#import "changePastInfo.h"
#import "Profile.h"



@implementation ProfileDetailViewController
<<<<<<< .mine
@synthesize profiledetail2;
@synthesize pageNumberLabel;
@synthesize segmentControl;
@synthesize cinfo;
@synthesize editbutton;
@synthesize cgpaLabel;
@synthesize creditsLabel;
@synthesize semesterLabel;
=======
>>>>>>> .r69

@synthesize cinfo, editbutton, userInputGPA, userInputSemester, userInputCredits;



<<<<<<< .mine

- (IBAction) detailview:(id)sender {
	selectview = [self.segmentControl selectedSegmentIndex];
	
	
	if (selectview==0) {
		
		ProfileDetail2 *pDetail= [[ProfileDetail2 alloc] initWithNibName:@"ProfileDetail2" bundle:nil];
		self.profiledetail2 = pDetail;
		[pDetail release];
		
	} 
	
	
	
	//else if (selectview==1) { 
		
		
		//push view
		//ProfileDetail2 *pDetail= [[ProfileDetail2 alloc] initWithNibName:@"ProfileDetail2" bundle:nil];
		//self.profiledetail2 = pDetail;
		//[pDetail release];
		
	//}
	[self.navigationController pushViewController:profiledetail2 animated:YES];
	//[self.navigationController pushViewController:profiledetailview animated:YES];
	//NSLog(@"%@", semester);
}



// Load the view nib and initialize the pageNumber ivar.
- (id)initWithPageNumber:(int)page {
    if (self = [super initWithNibName:@"ProfileDetailView" bundle:nil]) {
        pageNumber = page;
    }
    return self;
}


//If user chooses to create a new profile
//the view will change to profile creation
- (IBAction) createPressed:(id)sender {
	if (self.profiledetail2 == nil){
		ProfileDetail2 *pDetail= [[ProfileDetail2 alloc] initWithNibName:@"ProfileDetail2" bundle:nil];
		self.profiledetail2 = pDetail;
		[pDetail release];
	}
	
	[self.navigationController pushViewController:profiledetail2 animated:YES];
} //createPressed

=======
>>>>>>> .r69
- (void)editAction:(id)sender{
	if (self.cinfo == nil){
		ChangePastInfo * c= [[ChangePastInfo alloc] initWithNibName:@"ChangePastInfo" bundle:nil];
		self.cinfo = c;
		[c release];
	}
	
	[self.navigationController pushViewController:cinfo animated:YES];
} //createPressed


- (void)viewDidLoad {
    [super viewDidLoad];
	
	
	UIBarButtonItem *editButton = [[UIBarButtonItem alloc] initWithTitle:@"Edit" 
																	 style:UIBarButtonItemStyleBordered 
																	target:self 
																	action:@selector(editAction:)]; 
	self.navigationItem.rightBarButtonItem = editButton; 
	[editButton release]; 
	
	// create a custom navigation bar button and set it to say "back"
	UIBarButtonItem *temporaryBarButtonItem = [[UIBarButtonItem alloc] init];
	temporaryBarButtonItem.title = @"Back";
	self.navigationItem.backBarButtonItem = temporaryBarButtonItem;
	[temporaryBarButtonItem release];
}

- (void)viewDidUnload
{
   
    self.editbutton = nil;
}


-(void)viewWillAppear:(BOOL)animated {
	NSLog(@"view will appear");
   Profile *profile = [Profile sharedProfile];
<<<<<<< .mine
	//NSString *tempDisplay = [[NSString alloc] initWithFormat: @"This profile belongs to %@", [profile getUserName]];
=======
>>>>>>> .r69
	
<<<<<<< .mine
	NSString *myname = [[NSString alloc] initWithFormat: @"%@", [profile getUserName]];
=======
	userInputGPA.text = [profile getCGPA];
>>>>>>> .r69
	
<<<<<<< .mine
	
	//changePastInfo *grade = mycgpa;
	NSString *tempDisplay1 = [[NSString alloc] initWithFormat: @"%@", [profile getCGPA]];
	cgpaLabel.text = tempDisplay1;
	
	NSString *tempDisplay2 = [[NSString alloc] initWithFormat: @"%@", [profile getCredits]];
	creditsLabel.text = tempDisplay2;
	
	NSString *tempDisplay3 = [[NSString alloc] initWithFormat: @"%@", [profile getSemester]];
	semesterLabel.text = tempDisplay3;
	[tempDisplay1 release];	
	[tempDisplay2 release];	
	[tempDisplay3 release];
	
	
=======
	userInputCredits.text = [profile getCreditsUsed];
	userInputSemester.text = [profile getSemester];
>>>>>>> .r69

	

}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning]; // Releases the view if it doesn't have a superview
    // Release anything that's not essential, such as cached data
}


- (void)dealloc {
<<<<<<< .mine
	[cgpaLabel release];
	[creditsLabel release];
	[semesterLabel release];
	[pageNumberLabel release];
=======
	[userInputGPA release];
	[userInputSemester release];
	[userInputCredits release];
>>>>>>> .r69
    [super dealloc];
}


@end

